#include <cstdio>
#include <algorithm>

// This file is the wrong answer; 
// we use it to show the dfs can not 
// bring you to the destination

#define INF 999999999
 
#define N 220

using namespace std; 

int a[N]; 
int n; 

int sum[N]; 

void dfs(int s, int e, int &rmin, int &rmax)
{
	int i, j, tmin1, tmax1, tmin2, tmax2, t; 
	int n2 = 2*n; 
	
	if (e==s) {
		rmin = rmax = 0; 
		return;
	}
	
	if (e==s+1) {
		rmin = rmax = a[s] + a[e]; 
		return; 
	}
	
	rmin = INF; 
	rmax = 0; 
	for (i=s; i<e; i++) {
		dfs(s, i, tmin1, tmax1); 
		dfs(i+1, e, tmin2, tmax2); 
		t = sum[e] - sum[s-1]; 
		rmin = min(rmin, tmin1+tmin2+t); 
		rmax = max(rmax, tmax1+tmax2+t); 
	}
}


int main()
{
	int i; 
	int rmax, rmin, tmax, tmin; 	
	
	//freopen("p1880_1.in", "r", stdin); 
	
	scanf("%d", &n); 
	for (i=1; i<=n; i++) {
		scanf("%d", &a[i]); 
		a[n+i] = a[i]; 
		sum[i] = sum[i-1] + a[i]; 	
	}

	for (i=n+1; i<=2*n; i++) {
		sum[i] = sum[i-1] + a[i]; 
	}
	
	tmin = INF; 
	tmax = 0; 
	for (i=1; i<n; i++) {
		dfs(i, i+n-1, rmin, rmax); 
		tmin = min(tmin, rmin); 
		tmax = max(tmax, rmax); 
	}

	printf("%d\n%d\n", tmin, tmax); 

	return 0; 
}


